<?php
include "Includes/solotrn_sesion.php";
include "Includes/soloFun_Generales.php";
require_once "config.php";
require_once "Includes/conexion.class.php";

$strSql="select max(id1)+1 as id  from solotb_nivel1";
$oConexion = new Conexion($WORKFLOW["motor_base"], $WORKFLOW["db_usuario"], $WORKFLOW["db_password"], 
        $WORKFLOW["basedatos"], $WORKFLOW["servidor"], $WORKFLOW["flags"], $WORKFLOW["encoding"]);
if(!$oConexion->EjecutarQuery($strSql)) {
    $strERROR=1;
    $err=0;
}
$MaxId=$oConexion->getData("NUM");
$MaxId = $MaxId[0][0];
$oConexion->liberarResultado();
$oConexion->Cerrar();

$strSql="select * from solotb_nivel1 order by des";
$oConexion = new Conexion($WORKFLOW["motor_base"], $WORKFLOW["db_usuario"], $WORKFLOW["db_password"], 
        $WORKFLOW["basedatos"], $WORKFLOW["servidor"], $WORKFLOW["flags"], $WORKFLOW["encoding"]);

if(!$oConexion->EjecutarQuery($strSql)) {
    echo $oConexion->getErrorMessage();
    $strERROR=1;
    $err=0;
}

$arrData=$oConexion->getData("NUM");

$oConexion->liberarResultado();
$oConexion->Cerrar();

?>

<html>
    <head>
        <title>Documentacion</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <link rel="stylesheet" href="SoloStyles/Solostyles.css" type="text/css">
    </head>

    <body leftmargin=0 topmargin=0 marginwidth="0" marginheight="0">
        <p align="center" class="SoloStyle_TituloPaginas">Tabla de Subsecretar&iacute;as</p>
        <form name="frmIngreso" action= "trn_GrabaEmpresa.php" method="POST">
            <input type="hidden" name="opc" value="C">

            <table border="0" width="70%" align="center">
                <tr>
                    <td class="SoloStyle_Etiqueta"><b>Id</b></td>
                    <td class="SoloStyle_Texto"><?php echo $MaxId; ?><input type="hidden" maxlenght="50" size="50" name="HidId" class="texto" value="<?php echo $MaxId; ?>"></td>
                </tr>
                <tr>
                    <td class="SoloStyle_Etiqueta"><b>Nueva Subsecretar&iacute;a</b></td>
                    <td><input type="text" maxlenght="50" size="50" name="TxtDesc" class="SoloStyle_Texto"></td>
                </tr>
            </table>
            <br><center>
                <input type="button" name="CmdGrabar" value="Grabar" class="SoloStyle_Boton" onClick="Submit_Form(document.frmIngreso)"></center>

        </form>
        <table width="75%" border="0" align="center">
            <tr class="SoloStyle_Etiqueta">
                <td class="texto">Subsecretar&iacute;as</td>
                <td class="texto" width="20%">Acci&oacute;n</td>
            </tr>
            <?php for($i=0; $i < count($arrData); $i++ ) {
                $clase = "SoloStyle_Grid";
                if($i%2 > 0)
                    $clase = "SoloStyle_Texto";
                ?>

            <tr class="<?php echo $clase;?>">
                <td><?php echo $arrData[$i][1]; ?></td>

                <td><a href= "trn_GrabaEmpresa.php?id=<?php echo $arrData[$i][0]; ?>&ds=<?php echo $arrData[$i][1]; ?>&opc=M">
                        <img src='iconos/soloico_modificar.gif' alt='Modificar' width="23" height="19" border='0' style='cursor:hand' ></a>&nbsp;
                    <a href="#" onClick="Comprobar('trn_GrabaEmpresa.php?id=<?php echo $arrData[$i][0]; ?>&ds=<?php echo $arrData[$i][1]; ?>&opc=E')">
                        <img src='iconos/soloico_eliminar.gif' alt='Borrar Campos' width="23" height="19" border='0' style='cursor:hand'></a></td>
            </tr>
                <?php } ?>
        </table>
    </body>
</html>

<SCRIPT type="text/JavaScript" src="PHPMailer/fun_generales.js"></SCRIPT>

<script type="text/JavaScript">

    function Window_Onload(){
        var Mensaje;
        Mensaje = "<?php echo $_REQUEST["des"] ;?>";
        if ("<?php echo $_REQUEST["MiError"] ;?>"  != ""){

            if ("<?php echo $_REQUEST["MiError"]; ?>" == "0"){
                //Call Msgbox (, 64, "Aplicaci�n")
                alert(acentos("Operación OK"));
            }else{
                //Call Msgbox (Mensaje, 16, "Aplicaci�n")
                alert(acentos(Mensaje));
            }

        }
    }

    function Comprobar(pagina){
        //var conf = msgbox("Confirma Eliminar", VBOKCANCEL + VBQUESTION,"SoloPortal")
        var conf = confirm("Confirma Eliminar");
        if (conf)
            window.location.href = pagina;
    }

</script>